<%@ include file="/init.jsp"%>


<%@page import="java.util.StringTokenizer"%>
<%@page import="com.liferay.portal.service.ListTypeServiceUtil"%>
<%@page import="com.liferay.portal.model.ListType"%>
<%@ include file="/init.jsp"%>
<portlet:resourceURL var="ajaxCallResourceURL" />

<%
ListType mappedFee = (ListType) request.getAttribute("mappedFee");
System.out.println("doing ID >>>" + mappedFee.getListTypeId());

List<ListType> mappedSubFees = 
	ListTypeServiceUtil.getListTypes
		("com.teqbridgeltd.liferay.model.map.Fees." + mappedFee.getName() );
System.out.println("com.teqbridgeltd.liferay.model.map.Fees." + mappedFee.getName() +"<<<");

%>
		<aui:layout>
			<aui:column>
				<span class="hder" id="feesName_<%=mappedFee.getListTypeId() %>" ><%=mappedFee.getName() %></span>
			</aui:column>
		</aui:layout>
		
		<aui:layout>
			<aui:column columnWidth="33">
				<%
				List<ListType> layoutName = ListTypeServiceUtil.getListTypes("processing.fees.corf");
				%>
				<strong>Zone/Layout</strong>
				<select  disabled="disabled" id="layout_<%=mappedFee.getListTypeId() %>" name="layout_<%=mappedFee.getListTypeId() %>" label="" >
				<option style="font-style: italic; color: #A0A0A4" value="">--Please Select Layout--</option>
			  	<%
			   
			  	for(int i=0; i<layoutName.size(); i++){
			  		ListType _layoutName = layoutName.get(i);
			  		//20|A02.COR.processingfees.IKOT OMIN
			  		StringTokenizer strTok = new StringTokenizer(_layoutName.getName(), "|");
			  		String fee = strTok.nextToken();
			  		String secondPart = strTok.nextToken();
			  		String ___layout = secondPart.substring(secondPart.indexOf("processingfees") + "processingfees.".length());
			  		System.out.println("fee>>" + fee);
			  		System.out.println("___layout>>" + ___layout);
			  		
			  	%>	
			  	<option value="<%=fee %>"><%=___layout  %></option>
			  	<%
			  	}
			  	%>
				</select>
			</aui:column>
			<aui:column columnWidth="33">
				<strong>Area (Sq Meters):</strong>
				<input readonly="readonly" id="area_<%=mappedFee.getListTypeId() %>" name="area_<%=mappedFee.getListTypeId() %>" type="text"></input>
			</aui:column>
			<aui:column columnWidth="33">
				<input class="resultbox" readonly="readonly" name="result_<%=mappedFee.getListTypeId() %>"  id="result_<%=mappedFee.getListTypeId() %>" type="text" value="">
			</aui:column>
		</aui:layout>
		
		
		<aui:layout>
			<aui:column>
				<input type="button"  onClick="ComputeFee_<%=mappedFee.getListTypeId() %>();" name="compute_result_<%=mappedFee.getListTypeId() %>" value="Compute"></input>
			</aui:column>
		</aui:layout>
		
<script>
function ComputeFee_<%=mappedFee.getListTypeId() %>(){
	try{
		var result = document.getElementById('result_<%=mappedFee.getListTypeId() %>');
		var area = document.getElementById('area_<%=mappedFee.getListTypeId() %>').value;
		var layout =  document.getElementById('layout_<%=mappedFee.getListTypeId() %>').value;
		result.value = layout * area;
		hidePrintButton();
		computeTotal();
	}catch(err){
	  txt="There was an error on this page.\n\n";
	  err.message
	  txt+="Error description: " + err.description + "\n\n";
	  txt+="Click OK to continue.\n\n";
	  txt+=err.message + "\n\n";
	  alert(txt);
	}
	
}
</script>

